import axios from 'axios';
import { Toast } from 'vant';
// import {PATH} from './PATH';
// const request = axios.create({
//     baseURL: 'http://127.0.0.1:8848',
//     timeout: 5000, 
//     responseType: "json",
//     withCredentials: false,
//     headers: {
//       "Content-Type": "application/json;charset=utf-8"
//     }
//   })

let mytoast = null

// axios.defaults.baseURL = 'http://127.0.0.1:8848'
axios.defaults.baseURL = 'http://111.229.157.253:8848'
axios.defaults.timeout = 5000

axios.interceptors.request.use((config)=>{
  const token = sessionStorage.getItem("token")
  if(token) config.headers['authorization'] = token
  mytoast = Toast.loading({
    duration: 0,
    forbidClick: true,
    message: "加载中..."
  })
  return config
})

axios.interceptors.response.use((config)=>{
  // console.log(config);
  mytoast.clear()
  return config
})

export default axios